import request from '@/utils/request'

// 获取摊位管理列表
export function fetchProducts(businessId, productName, saleDate) {
  const data = {
    businessId,
    productName,
    saleDate
  }
  return request({
    url: '/api/v2/backend/purchase/traceback/sale_product',
    method: 'post',
    data
  })
}

export function fetchBuyers(businessId, productName, saleDate, perPage, page) {
  const data = {
    businessId,
    productName,
    saleDate, 
    perPage, 
    page
  }
  data.purchaseDetailId = 1 // 测试用 实际需要删除
  return request({
    url: '/api/v2/backend/purchase/traceback/buy_member',
    method: 'post',
    data
  })
}

export function fetchRecalls(businessId, productName, saleDate, perPage, page) {
  const data = {
    businessId,
    productName,
    saleDate, 
    perPage, 
    page
  }
  data.purchaseDetailId = 1 // 测试用 实际需要删除
  return request({
    url: '/api/v2/backend/purchase/traceback/recall_list',
    method: 'post',
    data
  })
}

export function fetchUpperReaches(businessId, productName, saleDate) {
  const data = {
    businessId,
    productName,
    saleDate
  }
  data.purchaseDetailId = 1 // 测试用 实际需要删除
  return request({
    url: '/api/v2/backend/purchase/traceback/upper_reaches',
    method: 'post',
    data
  })
}

export function addRecall(businessId, productName, saleDate, pushMessage) {
  const data = {
    businessId,
    productName,
    saleDate,
    pushMessage
  }
  data.purchaseDetailId = 1 // 测试用 实际需要删除
  return request({
    url: '/api/v2/backend/purchase/traceback/add_recall',
    method: 'post',
    data
  })
}